#!/usr/bin/env python
from xml.dom.minidom import parse, Node
import sys
import getopt

def main(argv):
  weeks = ['A', 'B']
  days = ['MO', 'TU', 'WE', 'TH', 'FR']
  tt = parse('ttjsh.xml')
  ttdatas = tt.getElementsByTagName("CellData")
  a = 0
  timetable = {}
  lessons = {}
  
  for lesson in range(6):
    for week in weeks:
      for day in days:
        a = a + 1
        timetable[week + day + str(lesson + 1)] = a
        lessons[a] = week + day + str(lesson + 1)
  
  a = 0
  for ttdata in ttdatas:
    if not ttdata.hasAttribute('IsRowHeader'):
      if ttdata.hasChildNodes():
        lesson = []
        lessonDetails = ttdata.getElementsByTagName("CellRow")
        for lessonDetail in lessonDetails.item(0).childNodes:
          if lessonDetail.nodeType == Node.TEXT_NODE:
            lesson.append(lessonDetail.data)
        for lessonDetail in lessonDetails.item(1).childNodes:
          if lessonDetail.nodeType == Node.TEXT_NODE:
            lesson.append(lessonDetail.data)
        timetable[lessons[a + 1]] = lesson
      else:
        timetable[lessons[a + 1]] = '-'
      a = a + 1

  for week in weeks:
    for day in days:
      for lesson in range(6):
        period = week + day + str(lesson + 1) 
        print period, timetable[period]  
  
if __name__ == "__main__":
  main(sys.argv[1:])
